package com.unohacha.qqj.fzdr.fragment;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadmoreListener;
import com.unohacha.qqj.fzdr.R;
import com.unohacha.qqj.fzdr.main.MaterialActivity;
import com.unohacha.qqj.mylibrary.base.BaseFragment;
import com.youth.banner.Banner;

import butterknife.BindView;

/**
 * 物资详情 
 */

public class MaterialFragment extends BaseFragment implements OnRefreshLoadmoreListener {

    @BindView(R.id.comment_banner)
    Banner commentBanner;
    @BindView(R.id.pt_line)
    ImageView ptLine;
    @BindView(R.id.car_list_recycler)
    RecyclerView carListRecycler;
    @BindView(R.id.mRefreshLayout)
    SmartRefreshLayout mRefreshLayout;
    
    private String type;//1. 原料行情 2. 设备行情
    private MaterialActivity materialActivity;
    private int page = 1;
    private String address_id;//地址Id
    private int app_cate_id;//分类ID

    public static MaterialFragment getInstance() {
        MaterialFragment sf = new MaterialFragment();
        return sf;
    }
    
    @Override
    protected void initBundle(Bundle arguments) {
        if (null != arguments){
            type = arguments.getString("type");
            address_id = arguments.getString("address_id");
            app_cate_id = arguments.getInt("app_cate_id");
        }
    }

    @Override
    protected int getLayoutId() {
        return R.layout.material_fragment;
    }

    @Override
    protected void initView(View rootView) {
        materialActivity = (MaterialActivity) getActivity();
        mRefreshLayout.setOnRefreshLoadmoreListener(this);
        mRefreshLayout.setRefreshHeader(new ClassicsHeader(materialActivity));
        mRefreshLayout.setRefreshFooter(new ClassicsFooter(materialActivity));
        carListRecycler.setLayoutManager(new LinearLayoutManager(materialActivity, LinearLayoutManager.VERTICAL, false));
    }

    @Override
    protected void initData() {

    }

    //物资行情信息
    private void getWzHqData(){
        
    }
    
    
    @Override
    public void onLoadmore(RefreshLayout refreshlayout) {
        refreshlayout.getLayout().postDelayed(new Runnable() {
            @Override
            public void run() {
                page ++;
            }
        },2000);
    }

    @Override
    public void onRefresh(RefreshLayout refreshlayout) {
        refreshlayout.getLayout().postDelayed(new Runnable() {
            @Override
            public void run() {
                page = 1;
            }
        },2000);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
    }

}
